<?php	
	/*
		ROW FORMATTERS
			
			Row formatters are functions, which generate HTML from single row of data supplied. These functions are exclusively
			used by the outputSQLTable() function from output.php. Each row formatter must take one or two parameters. The first
			is the array of values as received from mysql_fetch_row() called in outputSQLTable() and the second is the array (!)
			of parameters needed for the formatter to do its job.
	*/


	/*
		Simplest row formatter. For each row creates a <tr> tag pair and outputs all values wrapped by <td> tag pair.
	*/
	
	function rowPlain($row) {
		$html = "<tr>";
		foreach($row as $i => $cell) $html .= "<td>$cell</td>";
		$html .= "</tr>";
		return $html;
	}
	
	
	/*
		This row formatter sets for each <td> tag a class. Additionally, the optional second parameter specifies the index
		of the value in $row, which will be used as a class for the whole <tr> tag.
		
		$params:
			$classes	Array of classes, to be assigned to each corresponding td tag.
			$tr_col		Index of the value, whose value is to be used as the class for the <tr> tag.
	*/
	function rowClassed($row, $params) {
		$classes = $params[0];
		@$tr_col  = $params[1];
		
		if (isset($tr_col)) {
			$html = "<tr class=\"$row[$tr_col]\">";
		} else {	
			$html = "<tr>";
		}
		
		foreach($row as $i => $cell) {
			if (isset($classes[$i])) {
				$html .= "<td class=\"$classes[$i]\">$cell</td>";
			} else {
				$html .= "<td>$cell</td>";
			}
		}
		
		$html .= "</tr>";
		
		return $html;
	}
?>